package test2;

import java.io.*;
import java.util.ArrayList;

public class ReaderDao extends Thread {
    private File file;

    public ReaderDao(File f) {
        this.file = f;
    }

    @Override
    public void run() {
        while (true) {
            if (file != null) {
                synchronized (file) {
                    try {
                        FileInputStream fis = new FileInputStream(file);
                        BufferedInputStream bis=new BufferedInputStream(fis);
                        while (bis.read() != -1) {
                        }
                        //"路径" + file.getAbsolutePath() +
                        System.out.println("文件" + file.getName() + "读取完成");
                        break;
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else {
                break;
            }
        }
    }
}